package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReturnsIfTheGivenIntArraysHaveTheSameLengthAndContainTheSameValuesInTheSameOrder {
	public static void main(String[] argv) {
		int[] first = new int[]{34, 35, 36, 37, 37, 37, 67, 68, 69};
		int[] second = new int[]{34, 35, 36, 37, 37, 37, 67, 68, 69};
		System.out.println("两个 int 数组是否相等？" + equals(first, second));
	}

	public static boolean equals(int[] first, int[] second) {
		if (first == second)
			return true;

		if (first == null || second == null)
			return false;

		if (first.length != second.length)
			return false;

		for (int i = 0; i < second.length; i++) {
			if (first[i] != second[i])
				return false;
		}
		return true;
	}

	public static boolean equals(byte[] first, byte[] second) {
		if (first == second)
			return true;

		if (first == null || second == null)
			return false;

		if (first.length != second.length)
			return false;

		for (int i = 0; i < second.length; i++) {
			if (first[i] != second[i])
				return false;
		}
		return true;
	}
}
